package sk.tuke.magsa.personalistika;

import sk.tuke.magsa.framework.*;
import sk.tuke.magsa.personalistika.dao.*;
import sk.tuke.magsa.personalistika.dao_impl.*;
import sk.tuke.magsa.personalistika.ui.*;

public class Application {
    private static Application instance;

    private final ConnectionPool pool = new ConnectionPool();
    
    private OddelenieDao oddelenieDao = new OddelenieDaoImpl(pool);

    public OddelenieDao getOddelenieDao()
    {
        return this.oddelenieDao;
    }
    private ZamestnanecDao zamestnanecDao = new ZamestnanecDaoImpl(pool);

    public ZamestnanecDao getZamestnanecDao()
    {
        return this.zamestnanecDao;
    }

    public static Application getInstance() {
        return instance;
    }

    private void menu() {
        int selection = 0;
        do
        {
            printMenu();
            try
            {
                selection = Integer.parseInt(Utilities.readLine());
            }
            catch (NumberFormatException e)
            {
                //do nothing, repeat loop
            }
            switch(selection)
            {
            case 0: new OddelenieTable().menu();
                break;
            case 1: new ZamestnanecTable().menu();
                break;
            }
        }
        while (selection != 2);
    }

    protected void printMenu()
    {
        System.out.println("(0) Oddelenia");
        System.out.println("(1) Zamestnanci");
        System.out.println("(2) Exit");
        System.out.println("Enter selection: ");
    }

    public static void main(String[] args) {
        instance = new Application();
        instance.menu();
    }    
}
